package com.bugpool.leilema.tc.controller;

import com.bugpool.leilema.tc.bean.entity.SysDept;
import com.bugpool.leilema.tc.bean.req.SysDeptReq;
import com.bugpool.leilema.tc.service.DeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author wh
 * @Description 部门管理
 * @Date 2023/6/8 10:51
 * @Version 1.0
 **/
@RestController
@RequestMapping("/dept")
@Api(tags = "部门控制器")
public class DeptController {

    @Resource
    private DeptService deptService;


    @ApiOperation("获取部门列表")
    @GetMapping("/list")
    public List<SysDept> list(SysDeptReq sysDeptReq){
       return deptService.list(sysDeptReq);
    }



    @GetMapping("/{deptId}")
    @ApiOperation("根据id 获取部门详情")
    public SysDept getDeptById(@PathVariable Long deptId){
             return deptService.getDeptById(deptId);
    }

    @PostMapping("/addDept")
    @ApiOperation("新增部门")
    public Boolean addDept(@RequestBody SysDept sysDept){
        return deptService.addDept(sysDept);
    }

    @PutMapping("/updateDept")
    @ApiOperation("更新部门")
    public Boolean updateDept(@RequestBody SysDept sysDept){
        return deptService.updateDept(sysDept);
    }

    @DeleteMapping("/{deptIds}")
    @ApiOperation("批量删除")
    public Boolean deleteDeptByIds(@PathVariable List<Long> deptIds){
        return deptService.deleteDeptByIds(deptIds);
    }






}
